package routers

import (
	"github.com/astaxie/beego"
	"lazyops_go/opsControllers"
)

func init() {

	//找到路由后执行controller 之前

	beego.InsertFilter("/ops/*", beego.BeforeExec, PermsFilter)

	//saltstack
	beego.Router("/ops/salt/", &opsControllers.OpsController{}, "get:IndexSalt")
	beego.Router("/ops/cmd/", &opsControllers.OpsController{}, "post:ExecCmd")
	beego.Router("/ops/script/", &opsControllers.OpsController{}, "post:ExecScript")
	beego.Router("/ops/upfile/", &opsControllers.OpsController{}, "post:UploadFile")
	beego.Router("/ops/cmdkey/", &opsControllers.OpsController{}, "post:GetCmd")

	beego.Router("/ops/script/", &opsControllers.OpsController{}, "get:IndexScript")
	beego.Router("/ops/script/:page/", &opsControllers.OpsController{}, "get:IndexScript")
	beego.Router("/ops/addscript/", &opsControllers.OpsController{}, "post:CreateScript")
	beego.Router("/ops/idscript/", &opsControllers.OpsController{}, "post:GetScript")
	beego.Router("/ops/editscript/", &opsControllers.OpsController{}, "post:EditScript")
	beego.Router("/ops/delscript/", &opsControllers.OpsController{}, "post:DelScript")
	beego.Router("/ops/deployscript/", &opsControllers.OpsController{}, "post:DeployScript")

	beego.Router("/ops/smb/", &opsControllers.OpsController{}, "get:IndexSmb")
	beego.Router("/ops/addsmbuser/", &opsControllers.OpsController{}, "post:AddSmbUser")
	beego.Router("/ops/getperms/", &opsControllers.OpsController{}, "post:GetPerms")
	beego.Router("/ops/setperms/", &opsControllers.OpsController{}, "post:SetPerms")
	beego.Router("/ops/setpasswd/", &opsControllers.OpsController{}, "post:ChangePasswd")
	beego.Router("/ops/deluser/", &opsControllers.OpsController{}, "post:DelSmbUser")

}
